const Sequelize = require('sequelize')
const sequelize = require('../mysql')
const Project = require('./projectModel')
class Menu extends Sequelize.Model { }
Menu.init({
  id: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    autoIncrement: true,
    unique: true,
    primaryKey: true
  },
  projectId: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    allowNull: false
  },
  parentId: Sequelize.INTEGER(11).UNSIGNED,
  name: {
    type: Sequelize.STRING(120),
    allowNull: false,
    unique: true
  },
  code: Sequelize.STRING(255)
}, { sequelize, modelName: 'menu' })
Menu.belongsTo(Project, { foreignKey: 'projectId', targetKey: 'id' })
Menu.sync({ force: false })
module.exports = Menu
